return function()
  -- 定义配色
  local colors = {
    blue = '#48bfe3',
    cyan = '#80ffdb',
    black = '#080808',
    white = '#c6c6c6',
    red = '#ff5189',
    violet = '#7678ed',
    grey = '#303030',
    gray = '#808080',
    yellow = '#eccc68',
    orange = '#FF8800',
  }
  -- 设置配色
  local bubbles_theme = {
    normal = {
      a = { fg = colors.black, bg = colors.violet },
      b = { fg = colors.white, bg = colors.grey },
      c = { fg = colors.gray, bg = colors.black },
    },
    insert = { a = { fg = colors.black, bg = colors.blue } },
    command = { a = { fg = colors.black, bg = colors.orange } },
    visual = { a = { fg = colors.black, bg = colors.cyan } },
    replace = { a = { fg = colors.black, bg = colors.red } },
    inactive = {
      a = { fg = colors.white, bg = colors.black },
      b = { fg = colors.white, bg = colors.black },
      c = { fg = colors.gray, bg = colors.black },
    },
  }

  -- 定义显示条件
  local buffer_not_empty = function()
    return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
  end

  local hide_in_width = function()
    return vim.fn.winwidth(0) > 80
  end

  -- 获取工作目录
  local function get_cwd()
    local cwd = vim.fn.getcwd()
    local is_windows = require('core.global').is_windows
    if not is_windows then
      local home = require('core.global').home
      if cwd:find(home, 1, true) == 1 then
        cwd = '~' .. cwd:sub(#home + 1)
      end
      local split_cwd = vim.split(cwd, '/')
      if #split_cwd > 3 then
        cwd = table.concat({ split_cwd[1], '…', split_cwd[#split_cwd - 1], split_cwd[#split_cwd] }, '/')
      else
        cwd = table.concat(split_cwd, '/')
      end
    else
      cwd = cwd:gsub('\\', '/')
      local split_cwd = vim.split(cwd, '/')
      if #split_cwd > 3 then
        cwd = table.concat({ split_cwd[1], '…', split_cwd[#split_cwd - 1], split_cwd[#split_cwd] }, '/')
      else
        cwd = table.concat(split_cwd, '/')
      end
    end
    return ' ' .. cwd
  end
  -- 设置显示LSP名称
  local lsp_name = function()
    if rawget(vim, 'lsp') then
      for _, client in ipairs(vim.lsp.get_active_clients()) do
        if client.attached_buffers[vim.api.nvim_get_current_buf()] and client.name ~= 'null-ls' then
          return (' LSP [' .. client.name .. ']') or ' LSP '
        end
      end
    end
  end
  -- lsp progress
  local lsp_progress = function()
    if not rawget(vim, 'lsp') then
      return ''
    end
    local Lsp = vim.lsp.util.get_progress_messages()[1]
    local msg = Lsp.message or ''
    local percentage = Lsp.percentage or 0
    local title = Lsp.title or ''
    local spinners = { '', '󰪞', '󰪟', '󰪠', '󰪢', '󰪣', '󰪤', '󰪥' }
    local ms = vim.loop.hrtime()
    local frame = math.floor(ms) % #spinners
    local content = string.format(' %%<%s %s %s (%s%%%%) ', spinners[frame + 1], title, msg, percentage)
    return content or ''
  end
  -- 设置显示代码模块名称
  local code_context = function()
    if vim.fn.winwidth(0) > 80 then
      local ok_navic, navic = pcall(require, 'nvim-navic')
      if ok_navic then
        return ' ' .. navic.get_location()
      else
        return ''
      end
    else
      return ''
    end
  end

  -- 自定义排除项
  local mini_sections = {
    lualine_a = {},
    lualine_b = {},
    lualine_c = {},
    lualine_x = {},
    lualine_y = {},
    lualine_z = {},
  }
  local outline = {
    sections = mini_sections,
    filetypes = { 'lspsagaoutline' },
  }
  local diffview = {
    sections = mini_sections,
    filetypes = { 'DiffviewFiles' },
  }

  require('lualine').setup({
    options = {
      theme = bubbles_theme,
      component_separators = '',
      section_separators = { left = ' ', right = ' ' },
    },
    sections = {
      lualine_a = {
        {
          'mode',
          separator = { right = ' ' },
          right_padding = 2,
          icon = '',
        },
      },
      lualine_b = {
        { 'filename', cond = buffer_not_empty },
        { 'branch' },
        {
          'diff',
          symbols = { added = ' ', modified = ' ', removed = ' ' },
          cond = hide_in_width,
        },
      },
      lualine_c = {
        { get_cwd, cond = hide_in_width },
        { code_context, cond = hide_in_width },
      },
      lualine_x = {
        {
          'diagnostics',
          sources = { 'nvim_diagnostic' },
          symbols = { Error = ' ', Warn = ' ', Info = ' ', Hint = '󰭻 ' },
          diagnostics_color = {
            color_error = { fg = colors.red },
            color_warn = { fg = colors.yellow },
            color_info = { fg = colors.cyan },
            color_hint = { fg = colors.blue },
          },
          cond = hide_in_width,
        },
        { lsp_name, cond = hide_in_width },
        { lsp_progress, cond = hide_in_width },
      },
      lualine_y = {
        'filetype',
        {
          'fileformat',
          symbols = {
            unix = 'LF',
            dos = 'CRLF',
          },
        },
        'progress',
      },
      lualine_z = {
        {
          'location',
          separator = { left = ' ' },
          left_padding = 2
        },
      },
    },
    inactive_sections = {
      lualine_a = { 'filename' },
      lualine_b = {},
      lualine_c = {},
      lualine_x = {},
      lualine_y = {},
      lualine_z = { 'location' },
    },
    tabline = {},
    winbar = {},
    extensions = { 'nvim-tree', 'toggleterm', 'lazy', 'nvim-dap-ui', outline, diffview },
  })
end
